#include "carina/common/testing.hh"

#include <iomanip>

// Here we test the capabilities of the logging object.

CE_TEST("Testing logging read back capabilities.")
{
    const char* message = "Hello world!";
    Carina::Log::message(Carina::CE_LOG_INFO, message);
    
    Carina::string result;
    result = Carina::Log::read();
    
    CE_ASSERT(!result.empty(), "Something was written to the log. It should not be empty!");
    CE_ASSERT(result.find(message) != Carina::string::npos, "Message is not present in the log stream");
    
    Carina::Log::stream(Carina::CE_LOG_INFO) << "And" << std::setw(3) << 42 << " is the answer" << std::endl;
    
    result = Carina::Log::read();
    CE_ASSERT(result.find(message) != Carina::string::npos, "Old messages should be still around.");
    CE_ASSERT(result.find("And 42 is the answer"), "Manipulators are not handled correctly.");
}